import java.util.*;

// 飞行棋分组
public class LudoGrouping {
    public static boolean solution(String pieces) {
        // 将输入字符串转换为整数数组
        String[] numbersStr = pieces.split(" ");
        int[] numbers = new int[numbersStr.length];
        for (int i = 0; i < numbersStr.length; i++) {
            numbers[i] = Integer.parseInt(numbersStr[i]);
        }

        // 统计每个数字出现的次数
        Map<Integer, Integer> countMap = new HashMap<>();
        for (int num : numbers) {
            countMap.put(num, countMap.getOrDefault(num, 0) + 1);
        }

        // 检查每个数字的出现次数是否是5的倍数
        for (int count : countMap.values()) {
            if (count % 5 != 0) {
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        // 测试用例
        System.out.println(solution("1 2 3 4 5") == false);
        System.out.println(solution("1 1 1 1 2 1 2 2 2 2") == true);
        System.out.println(solution("1 1 1 1 1 2 2 2 2 2 3 3 3 3 3") == true);
        System.out.println(solution("1 1 1 1 2 2 2 2 3 3") == false);
    }
}